package com.ruoyi.web.controller.pollutant;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pollutant.domain.OutletNoise;
import com.ruoyi.pollutant.service.IOutletNoiseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 噪声排放Controller
 * 
 * @author yxf
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/pollutant/noise")
public class OutletNoiseController extends BaseController
{
    @Autowired
    private IOutletNoiseService outletNoiseService;

    /**
     * 查询噪声排放列表
     */
    @PreAuthorize("@ss.hasPermi('pollutant:noise:list')")
    @GetMapping("/list")
    public TableDataInfo list(OutletNoise outletNoise)
    {
        startPage();
        List<OutletNoise> list = outletNoiseService.selectOutletNoiseList(outletNoise);
        return getDataTable(list);
    }

    /**
     * 导出噪声排放列表
     */
    @PreAuthorize("@ss.hasPermi('pollutant:noise:export')")
    @Log(title = "噪声排放", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OutletNoise outletNoise)
    {
        List<OutletNoise> list = outletNoiseService.selectOutletNoiseList(outletNoise);
        ExcelUtil<OutletNoise> util = new ExcelUtil<OutletNoise>(OutletNoise.class);
        return util.exportExcel(list, "噪声排放数据");
    }

    /**
     * 获取噪声排放详细信息
     */
    @PreAuthorize("@ss.hasPermi('pollutant:noise:query')")
    @GetMapping(value = "/{noId}")
    public AjaxResult getInfo(@PathVariable("noId") Long noId)
    {
        return AjaxResult.success(outletNoiseService.selectOutletNoiseById(noId));
    }

    /**
     * 新增噪声排放
     */
    @PreAuthorize("@ss.hasPermi('pollutant:noise:add')")
    @Log(title = "噪声排放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OutletNoise outletNoise)
    {
        return toAjax(outletNoiseService.insertOutletNoise(outletNoise));
    }

    /**
     * 修改噪声排放
     */
    @PreAuthorize("@ss.hasPermi('pollutant:noise:edit')")
    @Log(title = "噪声排放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OutletNoise outletNoise)
    {
        return toAjax(outletNoiseService.updateOutletNoise(outletNoise));
    }

    /**
     * 删除噪声排放
     */
    @PreAuthorize("@ss.hasPermi('pollutant:noise:remove')")
    @Log(title = "噪声排放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noIds}")
    public AjaxResult remove(@PathVariable Long[] noIds)
    {
        return toAjax(outletNoiseService.deleteOutletNoiseByIds(noIds));
    }
}
